package com.sls.mall.product.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author lixue
 * @Title: MallThreadConfig
 * @ProjectName sls_mall2021
 * @Description: TODO
 * @date 2021/5/514:48
 */
@Configuration
public class MallThreadConfig {

    @Bean
    public ThreadPoolExecutor threadPoolExecutor(MallThreadPoolConfigProperties pool)
    {
        return new ThreadPoolExecutor(
                pool.getCoreSize(),
                pool.getMaxSize(),
                pool.getKeepAliveTime(),
                TimeUnit.SECONDS,
                new LinkedBlockingDeque<>(100000),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy()

        );
    }

}
